package com.platform.controller.backend;

import com.github.pagehelper.PageInfo;
import com.platform.common.ServerResponse;
import com.platform.pojo.Permission;
import com.platform.service.IPermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * 操作权限
 */
@Controller
@RequestMapping(value = "/permissionController/")
public class PermissionController {

    @Autowired
    private IPermissionService iPermissionService;


    @RequestMapping(value = "add.do",method = RequestMethod.POST)
    @ResponseBody
    public ServerResponse<String> addPermission(@RequestParam Map paramMap){
        return iPermissionService.insert(paramMap);
    }

    @RequestMapping(value = "del.do",method = RequestMethod.POST)
    @ResponseBody
    public ServerResponse<String> delPermission(int id){
        return iPermissionService.del(id);
    }

    @RequestMapping(value = "update.do",method = RequestMethod.POST)
    @ResponseBody
    public ServerResponse<Permission> updatePermission(@RequestParam Map paramMap){
        return iPermissionService.update(paramMap);
    }

    @RequestMapping(value = "selectByRoleCode.do",method = RequestMethod.GET)
    @ResponseBody
    public ServerResponse<PageInfo> selectByRoleCode(@RequestParam Map paramMap){

        return iPermissionService.selectByRoleCode(paramMap);

    }

    /**
     * 列表页查询
     * @param param
     * @return
     */
    @RequestMapping(value = "selectByParam.do",method = RequestMethod.GET)
    @ResponseBody
    public ServerResponse<PageInfo> selectByParam(@RequestParam Map param, HttpServletRequest request){
        return iPermissionService.selectByParam(param);
    }

}
